Skip to content

[FRR] Support NHG information encoding and send to fpmsyncd for RIB/FIB - #26486

Open
GaladrielZhao wants to merge 6 commits into
sonic-net:masterfrom
GaladrielZhao:ribfib/build_send_nhg_fib
Open

[FRR] Support NHG information encoding and send to fpmsyncd for RIB/FIB#26486
GaladrielZhao wants to merge 6 commits into
sonic-net:masterfrom
GaladrielZhao:ribfib/build_send_nhg_fib

Conversation

@GaladrielZhao

Copy link
Copy Markdown
Contributor

Why I did it

This is one of the RIB/FIB PRs, to support sending enough NHG information to construct FIB in fpmsyncd.

How I did it

Use sonic-fib's Data Schema to encode zebra nexthop information as JSON string and send it to fpmsyncd as part of the RIB/FIB project. The modifications are in dplane_fpm_sonic.c and supervisord.conf.j2, and can be divided into four logical parts.

1 zebra info -> C_NextHopGroupFull -> C++ NextHopGroupFull -> JSON string
Add feature to build C_NextHopGroupFull (defined in sonic-fib),
and call sonic-fib's C-API to construct C++ NextHopGroupFull,
then return the JSON string back to zebra.

2 Encode JSON string as message and send to fpmsyncd:
Implement the encoding function and modify the fpm_nl_enqueue's
DPLANE_OP_NH_XXXX case to call the new one.

3 Add DEVICE_METADATA config to enable RIB/FIB feature
Read DEVICE_METADATA.localhost.nhg_fib from ConfigDB to conditionally
pass the --nhg-fib flag to zebra at startup via supervisord.conf.j2,
enabling the RIB/FIB NHG full encoding.

4 vtysh command to control FIB log level at runtime
Add fpm fib-log-level <debug|info|warn|error> command to dynamically
adjust the FIB library log level, bridging fib::LogLevel in sonic-fib
with zebra's native logging system.

How to verify it

  • Phoenixwing test
  • PR sanity

A picture of a cute animal (not mandatory but encouraged)

image

@GaladrielZhao
GaladrielZhao requested a review from lguohan as a code owner March 31, 2026 17:06
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@yxieca

yxieca commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

/azpw ms_conflict

3 similar comments
@yxieca

yxieca commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

/azpw ms_conflict

@yxieca

yxieca commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

/azpw ms_conflict

@yxieca

yxieca commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

/azpw ms_conflict

@yxieca

yxieca commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

/azpw ms_conflict

3 similar comments
@yxieca

yxieca commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

/azpw ms_conflict

@yxieca

yxieca commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

/azpw ms_conflict

@yxieca

yxieca commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

/azpw ms_conflict

@GaladrielZhao
GaladrielZhao force-pushed the ribfib/build_send_nhg_fib branch from e059db1 to 508a0f9 Compare April 30, 2026 13:06
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@yxieca

yxieca commented May 4, 2026

Copy link
Copy Markdown
Contributor

/azpw ms_conflict

3 similar comments
@yxieca

yxieca commented May 7, 2026

Copy link
Copy Markdown
Contributor

/azpw ms_conflict

@yxieca

yxieca commented May 11, 2026

Copy link
Copy Markdown
Contributor

/azpw ms_conflict

@yxieca

yxieca commented May 13, 2026

Copy link
Copy Markdown
Contributor

/azpw ms_conflict

@GaladrielZhao
GaladrielZhao force-pushed the ribfib/build_send_nhg_fib branch from 508a0f9 to 4365ae5 Compare May 21, 2026 08:27
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@GaladrielZhao
GaladrielZhao force-pushed the ribfib/build_send_nhg_fib branch from 6f5d005 to 2d5c63c Compare June 18, 2026 17:03
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@GaladrielZhao
GaladrielZhao force-pushed the ribfib/build_send_nhg_fib branch from 2d5c63c to 565c6d3 Compare June 18, 2026 17:12
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@eddieruan-alibaba eddieruan-alibaba moved this from In Progress to routing-review-needed in SONiC Routing Dashboard Jun 26, 2026
@GaladrielZhao
GaladrielZhao force-pushed the ribfib/build_send_nhg_fib branch from b123f21 to b9d52b7 Compare June 26, 2026 03:15
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@eddieruan-alibaba

Copy link
Copy Markdown
Collaborator

@venkit-nexthop can you help to review it again? @GaladrielZhao has already addressed all your comments.

Use sonic-fib's Data Schema to encode zebra nexthop information
as JSON string and send it to fpmsyncd as part of the RIB/FIB project.
The modifications are in dplane_fpm_sonic.c and supervisord.conf.j2,
and can be divided into four logical parts.

1 zebra info -> C_NextHopGroupFull -> C++ NextHopGroupFull -> JSON string
    Add feature to build C_NextHopGroupFull (defined in sonic-fib),
    and call sonic-fib's C-API to construct C++ NextHopGroupFull,
    then return the JSON string back to zebra.

2 Encode JSON string as message and send to fpmsyncd:
    Implement the encoding function and modify the fpm_nl_enqueue's
    DPLANE_OP_NH_XXXX case to call the new one.

3 Add DEVICE_METADATA config to enable RIB/FIB feature
    Read DEVICE_METADATA.localhost.nhg_fib from ConfigDB to conditionally
    pass the --nhg-fib flag to zebra at startup via supervisord.conf.j2,
    enabling the RIB/FIB NHG full encoding.

4 vtysh command to control FIB log level at runtime
    Add `fpm fib-log-level <debug|info|warn|error>` command to dynamically
    adjust the FIB library log level, bridging fib::LogLevel in sonic-fib
    with zebra's native logging system.

Signed-off-by: Yuqing Zhao <galadriel.zyq@alibaba-inc.com>
Signed-off-by: Yuqing Zhao <galadriel.zyq@alibaba-inc.com>
Signed-off-by: Yuqing Zhao <galadriel.zyq@alibaba-inc.com>
Signed-off-by: Yuqing Zhao <galadriel.zyq@alibaba-inc.com>
Signed-off-by: Yuqing Zhao <galadriel.zyq@alibaba-inc.com>
….common.j2

Signed-off-by: Yuqing Zhao <galadriel.zyq@alibaba-inc.com>
@GaladrielZhao
GaladrielZhao force-pushed the ribfib/build_send_nhg_fib branch from b9d52b7 to cbfb354 Compare July 2, 2026 15:36
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).


/* set nh_grp_full_list */
const struct nh_grp_full *nh_grp_full_list = dplane_ctx_get_nhe_nh_grp_full(ctx);
for (uint32_t i = 0; i < dplane_ctx_get_nhe_nh_grp_full_count(ctx); i++) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we copy nh_grp_full_list / depends / dependents without checking against the array sizes on the C_NextHopGroupFull side. Zebra already has overflow checks — we should probably do the same here so we don't write past the end of the struct.

* For recursive NH, we keep the nexthop information for convergence handling
*/
if (CHECK_FLAG(c_nhg->nhg_flags, NEXTHOP_GROUP_RECURSIVE)) {
const struct nexthop *nh = nhg->nexthop;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For recursive NHGs we use nhg->nexthop without a NULL check. If that group ever comes through empty, zebra will crash. A quick guard would be good.

* We can't use FRR's zlog here because no API for forwarding va_list, and
* we want to preserve the original log level and formatting as much as possible.
*/
fprintf(stderr, "[ZEBRA:FIB] %s:%d (%s) ", file, line, func);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The FIB log path is writing straight to fprintf(stderr). I understand the va_list limitation with zlog, but this will bypass the normal FRR log file / syslog setup and be annoying to operate. Could we format into a buffer and then call zlog_debug?

/* Get the default SRv6 context which contains seg6's src IP */
struct zebra_srv6 *srv6 = zebra_srv6_get_default();

c_nhg->nh_srv6 = malloc(sizeof(struct C_nexthop_srv6));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If malloc for nh_srv6 / seg6_segs fails, we keep going with a partial object and still try to encode JSON. Better to fail the encode and mark the dplane request as failed in that case.

0114-Provide-interface-when-installing-uninstalling-SRv6-uA-SIDs.patch
0115-zebra-Update-promiscuity-flag-silently-without-route.patch
0116-zebra-keep-route_node-lock-in-NB-RIB-route-lookup_next.patch
0117-Add-Dplane-definitions-and-functions-for-ribfib.patch

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The embedded 0117 patch is only a subset of FRR#21415, and it already diverges a bit (OPTION_NHG_FIB is 2005 here vs 2004 upstream because of kernel-mac-ext-learn). How are we planning to keep these in sync as 21415 moves?

FPM_SRV6_LOCALSID_ACTION_UDT46 = 21,
};

enum custoem_rtattr_nexthop_group {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nits while I'm here: custoem_rtattr_nexthop_group and is_recurisve look like typos. Also FPM_NHA_JSON_STR = 2 with nothing at 1 — intentional so we leave room for NHA_ID?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: routing-review-needed

Development

Successfully merging this pull request may close these issues.

8 participants